package com.gome.ocean.dao.model.websql;

import org.apache.commons.lang3.StringUtils;

/**
 * @author zhangguoqing 2016年11月27日 下午9:50:32
 * @since 5.0.0
 */
public class MysqlColumnJsonBean {

    private String  columnName;
    private String  oldColumnName;
    private String  columnType;
    private String  length;
    private Object  scale;
    private Boolean nullable;
    private Boolean primaryKey;
    private String  defaults;
    private String  comments;
    private Boolean autoIncrement;
    private Boolean unsigned;
    private Boolean zerofill;
    private String  charset;
    private String  collate;
    private Boolean binary;
    private String  values;
    private String  defaultsEnumValue;
    private String  defaultSetValue;
    private String  onUpdateTimestamp;
    private String  dbName;
    private String  tableName;

    public String getDbName() {
        return dbName;
    }

    public void setDbName(String dbName) {
        this.dbName = dbName;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(Object columnName) {
        this.columnName = this.parseStrByObject(columnName);
    }

    public String getOldColumnName() {
        return oldColumnName;
    }

    public void setOldColumnName(Object oldColumnName) {
        this.oldColumnName = this.parseStrByObject(oldColumnName);
    }

    public String getColumnType() {
        return columnType;
    }

    public void setColumnType(Object columnType) {
        this.columnType = this.parseStrByObject(columnType);
    }

    public String getLength() {
        return length;
    }

    public void setLength(Object length) {
        this.length = this.parseStrByObject(length);
    }

    public Object getScale() {
        return scale;
    }

    public void setScale(Object scale) {
        this.scale = this.parseStrByObject(scale);
    }

    public Boolean getNullable() {
        return nullable;
    }

    public void setNullable(Object nullable) {
        this.nullable = this.parseBooleanByObject(nullable);
    }

    public Boolean getPrimaryKey() {
        return primaryKey;
    }

    public void setPrimaryKey(Object primaryKey) {
        this.primaryKey = this.parseBooleanByObject(primaryKey);
    }

    public String getDefaults() {
        return defaults;
    }

    public void setDefaults(Object defaults) {
        this.defaults = this.parseStrByObject(defaults);
    }

    public String getComments() {
        return comments;
    }

    public void setComments(Object comments) {
        this.comments = this.parseStrByObject(comments);
    }

    public Boolean getAutoIncrement() {
        return autoIncrement;
    }

    public void setAutoIncrement(Object autoIncrement) {
        this.autoIncrement = this.parseBooleanByObject(autoIncrement);
    }

    public Boolean getUnsigned() {
        return unsigned;
    }

    public void setUnsigned(Object unsigned) {
        this.unsigned = this.parseBooleanByObject(unsigned);
    }

    public Boolean getZerofill() {
        return zerofill;
    }

    public void setZerofill(Object zerofill) {
        this.zerofill = this.parseBooleanByObject(zerofill);
    }

    public String getCharset() {
        return charset;
    }

    public void setCharset(Object charset) {
        this.charset = this.parseStrByObject(charset);
    }

    public String getCollate() {
        return collate;
    }

    public void setCollate(Object collate) {
        this.collate = this.parseStrByObject(collate);
    }

    public Boolean getBinary() {
        return binary;
    }

    public void setBinary(Object binary) {
        this.binary = this.parseBooleanByObject(binary);
    }

    public String getValues() {
        return values;
    }

    public void setValues(Object values) {
        this.values = this.parseStrByObject(values);
    }

    public String getDefaultsEnumValue() {
        return defaultsEnumValue;
    }

    public void setDefaultsEnumValue(Object defaultsEnumValue) {
        this.defaultsEnumValue = this.parseStrByObject(defaultsEnumValue);
    }

    public String getDefaultSetValue() {
        return defaultSetValue;
    }

    public void setDefaultSetValue(Object defaultSetValue) {
        this.defaultSetValue = this.parseStrByObject(defaultSetValue);
    }

    public String getOnUpdateTimestamp() {
        return onUpdateTimestamp;
    }

    public void setOnUpdateTimestamp(Object onUpdateTimestamp) {
        this.onUpdateTimestamp = this.parseStrByObject(onUpdateTimestamp);
    }

    private String parseStrByObject(Object obj) {
        if (null != obj && StringUtils.isNotBlank(obj.toString())) {
            return obj.toString();
        } else {
            return "";
        }
    }

    private Boolean parseBooleanByObject(Object obj) {
        if (obj != null && StringUtils.isNoneBlank(obj.toString())) {
            return Boolean.parseBoolean(obj.toString());
        } else {
            return false;
        }
    }

}
